<link rel="stylesheet" href="../src/css/pages/rulescriptDetail.css">

<div class="container-fluid hide">
    <form>
        <div class="row" style="margin-top: 20px;">
            <div class="form-horizontal col-md-12">
                <div class="form-group">
                    <label class="col-md-1 control-label">{{i18n-ruleName}}</label>

                    <div class="col-md-5">
                        <input class="form-control" id="rule-name" placeholder="{{i18n-ruleNameHolder}}" style="width:100%"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-1 control-label">{{i18n-ruleDesc}}</label>

                    <div class="col-md-5">
                        <input class="form-control" id="rule-comment" placeholder="{{i18n-ruleDescHolder}}" style="width:100%"/>
                    </div>
                </div>
                <div class="form-group">

                    <label class="col-md-1 control-label">{{i18n-dailyData}}</label>
                    <div class="col-md-2">
                        <select name="data-cycle" style="width:100%"></select>
                    </div>

                    <label class="col-md-1 control-label" style="padding-left: 0px">{{i18n-snapData}}</label>
                    <div class="col-md-2">
                        <select name="snap-cycle" style="width:100%"></select>
                    </div>

                </div>
                <div id="history-versions" class="form-group hide">
                    <label class="col-md-1 control-label">{{i18n-version}}</label>

                    <div class="col-md-5">
                        <select class="form-control" name="versions"></select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-1 control-label">{{i18n-isRun}}</label>

                    <div class="col-md-5">
                        <label class="radio-inline">
                            <input class="check" type="radio"name="is-run" value="1" checked="checked"> {{i18n-yes}}
                        </label>
                        <label class="radio-inline">
                            <input class="check" type="radio" name="is-run" value="0"> {{i18n-no}}
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-1 control-label">{{i18n-logLevel}}</label>

                    <div class="col-md-5">
                        <!-- DEBUG(3),INFO(2),WARN(1),ERROR(0); -->
                        <select class="form-control" name="script-logger-level" style="width:30%">
                            <option value="3">DEBUG</option>
                            <option value="2">INFO</option>
                            <option value="1">WARN</option>
                            <option value="0">ERROR</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-1 control-label">{{i18n-scriptType}}</label>

                    <div class="col-md-5">
                        <select class="form-control" name="rule-engine" style="width:30%">
                            <option value="python">python</option>
                            <option value="groovy">groovy</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-1 control-label">{{i18n-ignore}}</label>

                    <div class="col-md-5">
                        <label class="checkbox-inline">
                            <input class="check" type="checkbox" value="BuildAdSetAllSnaps" name="ignoreDataBuild">{{i18n-BuildAdSetAllSnaps}}
                        </label>
                        <label class="checkbox-inline">
                            <input class="check" type="checkbox" value="BuildAdGroupAllSnaps" name="ignoreDataBuild">{{i18n-BuildAdGroupAllSnaps}}
                        </label>
                        <label class="checkbox-inline">
                            <input class="check" type="checkbox" value="BuildAdSetDailySnaps" name="ignoreDataBuild">{{i18n-BuildAdSetDailySnaps}}
                        </label>
                        <label class="checkbox-inline">
                            <input class="check" type="checkbox" value="BuildAdGroupDailySnaps" name="ignoreDataBuild">{{i18n-BuildAdGroupDailySnaps}}
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-1 control-label">{{i18n-rule}}</label>

                    <div id="rule-script-div" class="col-md-7">
                        <div class="rule-script-area">
                            <textarea id="rule-script" class="form-control">
                        </textarea>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-8 text-center">
                        <button class="btn btn-default create-btn" id="button-save">{{i18n-save}}</button>
                    </div>
                </div>
            </div>
            <div class="form-horizontal col-md-6"></div>
        </div>
        <div style="margin-top: 20px;">
            <hr class="simple no-margin">
        </div>
        <div style="margin-top: 20px;">
            <div id="test-div" class="form-group row">
                <div class="form-group row col-md-4">
                    <div class="col-md-4 form-inline">
                        <select name="objective-type" class="form-control no-padding"
                                style="width:100%;">
                            <!--<option value="0">adGroupId</option>-->
                            <option value="1">adSetId</option>
                        </select>
                    </div>
                    <div class="col-md-8 no-padding">
                        <input id="objective-id" class="form-control no-padding" data-type="location"
                               placeholder="{{i18n-targetIdHolder}}">
                    </div>
                </div>
                <div class="form-group col-sm-3">
                    <div class="input-group date-area">
                        <input id="date-period" type="daterange"
                               class="form-control datepicker hasDatepicker"
                               ranges="ranges" placeholder="{{i18n-testTimeHolder}}"/>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
                <div class="form-group col-sm-3 ">
                    <a href="javascript:void(0)" class="btn btn-default"
                       id="button-select-point">
                        {{i18n-triggerPoint}}
                    </a>
                    &nbsp;&nbsp;
                    <a href="javascript:void(0)" class="btn btn-default create-btn btn-test hide">
                        {{i18n-execute}}
                    </a>
                </div>
            </div>
            <div class="form-group no-margin hide test-label">
                <label></label>
            </div>
            <!-- 测试结果-->
            <div class="form-group" id="test-result" style="margin-top: 20px;">
            </div>
        </div>
    </form>
</div>

<div id="select-point-modal" class="modal fade" tabindex="-1" role="dialog">
    <div class="c-modal-dialog modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">{{i18n-verifyTriggerPoint}}</h4>
            </div>
            <div class="modal-body">
                <div class="select-point-container" style="background-color: white;max-height: 550px;overflow-y: auto;">
                    <table class="table table-striped table-bordered table-hover" list-manager="select-point-list">
                        <thead>
                        <tr>
                            <th width="50px" th-name="select-radio">{{i18n-select}}</th>
                            <th width="150px" th-name="point" >{{i18n-triggerPoint}}</th>
                            <th width="300px" th-name="data">{{i18n-snap}}</th>
                        </tr>
                        </thead>
                        <tbody id="select-point-grid">
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" id="test-btn">{{i18n-execute}}</button>
                <button type="button" class="btn btn-default" id="export-btn">{{i18n-export}}</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">{{i18n-cancel}}</button>
            </div>
        </div>
    </div>
</div>

<script type="text/x-template" id="test-result-script">
    <div class="panel panel-info">
        <div class="panel-heading">{{i18n-resultTitle}}</div>
        <!-- widget div-->
        <div role="content" style="display: block;">
            <div class="panel-body">
                <!-- content goes here -->
                <div id="basic-info" style="margin-left:20px;">
                    <%
                    if(result && result != ''){
                    %>
                    <div class="row">
                        <label class="col-md-1 control-label">{{i18n-resultLabel}}</label>

                        <div class="col-md-11"><span><%=result%></span></div>
                    </div>
                    <%
                    }
                    %>

                    <%
                    if(exceptionMsg && exceptionMsg != ''){
                    %>
                    <div class="row" style="color:red;">
                        <label class="col-md-1 control-label ">{{i18n-errorLabel}}</label>

                        <div class="col-md-11"><span><%=exceptionMsg%></span></div>
                    </div>
                    <%
                    }
                    %>

                    <%
                    if(logs && logs != ''){
                    %>
                    <div class="row"><label class="col-md-1 control-label">{{i18n-console}}</label>

                        <div class="col-md-11"><p class="alert alert-info no-margin">
                            <%=logs%>
                        </p></div>
                    </div>
                    <%
                    }
                    %>
                </div>
            </div>
        </div>
        <!-- end widget div -->
    </div>
</script>
